package cn.zwx.multi_datasource_example.config;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.apache.ibatis.transaction.Transaction;
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;

import javax.sql.DataSource;

/**
 * @description: 支持Service内多数据源切换的Factory
 * @projectName:multi_datasource_example
 * @see:cn.zwx.multi_datasource_example.config
 * @author:zhangwenxue
 * @createTime:2021/8/15 23:18
 * @version:1.0
 */
public class MultiDataSourceTransactionFactory extends SpringManagedTransactionFactory {
    @Override
    public Transaction newTransaction(DataSource dataSource, TransactionIsolationLevel level, boolean autoCommit) {
        return new MultiDataSourceTransaction(dataSource);
    }
}
